<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>圆环菜单</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <div class="circle-menu">
        <div class="circle-menu-switch">菜单</div>
        <div class="circle-menu-container">
            <div class="circle-menu-item"></div>
            <div class="circle-menu-item"></div>
            <div class="circle-menu-item"></div>
            <div class="circle-menu-item"></div>
            <div class="circle-menu-item"></div>
        </div>
    </div>
    <script>
        var angle = 90 / 4;
        var r = 200;
        var item = document.querySelectorAll('.circle-menu-item');
        for (let i = 0; i < item.length; i++) {
            var ele = item[i];
            // 通过三角函数，计算出 left,top的值
            // sin(角度) = > Math.sin(角度 * Math.PI / 180)
            // cos(角度) = > Math.cos(角度 * Math.PI / 180)
            ele.style.top = -1 * Math.sin(angle * i * Math.PI / 180) * r - 50 + 'px';
            ele.style.left = -1 * Math.cos(angle * i * Math.PI / 180) * r - 50  + 'px';
            ele.innerHTML = i;
        }

    </script>
</body>

</html>